#ifndef LOGGEDINFORM_H
#define LOGGEDINFORM_H

#include <QDateTime>
#include <QHash>
#include <QList>
#include <QMessageBox>
#include <QString>
#include <QStringList>
#include <QStringListModel>
#include <QTimer>
#include <QWidget>

#include "asynctask.h"
#include "contactsrequest.h"
#include "message.h"
#include "messagesrequest.h"
#include "postmessagerequest.h"

namespace Ui {
class LoggedInForm;
}

class LoggedInForm : public QWidget
{
    Q_OBJECT
    
public:
    explicit LoggedInForm(QWidget *parent = 0);
    ~LoggedInForm();

public slots:
    void onLoginSuccess(QString);
    void onContactsRequestSuccess(QStringList, QStringList);
    void onMessagesRequestSuccess(QHash<QString, QList<Message> > *);
    void onContactClicked(QModelIndex);
    void onSendButtonClicked();
    void onTimerExpiration();
    void error(QString);
    
private:
    Ui::LoggedInForm *ui;
    QStringListModel *contactsModel_;
    QStringListModel *messagesModel_;
    QTimer *downloadTimer_;

    AsyncTask *contactsTask_;
    AsyncTask *messagesTask_;
    AsyncTask *postMessageTask_;
    ContactsRequest *contactsRequest_;
    MessagesRequest *messagesRequest_;
    PostMessageRequest *postMessageRequest_;

    QStringList names_;
    QStringList numbers_;

    QString currentNumber_;
    QString cookieData_;

    QHash<QString, QList<Message> > messagesFromNumbers_;
};

#endif // LOGGEDINFORM_H
